<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Article extends CI_Controller {
	private $catalogs;
	public function __construct(){
		parent::__construct();
		$this->load->model("Catalog_model");
		$this->load->helper('url');
		$this->load->model("Article_model");
		$this->catalogs = $this->Catalog_model->get_all();
	}


	public function index()
	{	
		
		$articles = $this->Article_model->get_all();
		$data=array(
			"articles"=>$articles,
			"catalogs"=>$this->catalogs,
			"catalog_id"=>0,
			);
		$this->load->view('Article_index',$data);
	}


	public function view($id)
	{	
		
		$article= $this->Article_model->get_one($id);
		$this->Article_model->view_once($id);
		$data=array(
			"article"=>$article,
			"catalogs"=>$this->catalogs,
			"catalog_id"=>$article->catalog_id
			);
		$this->load->view('Article_view',$data);

	}
	public function lists($catalog_id)
	{	
		
		$articles = $this->Article_model->get_by_catalog_id($catalog_id);
		$data=array(
			"articles"=>$articles,
			"catalogs"=>$this->catalogs,
			"catalog_id"=>$catalog_id
			);
		$this->load->view('Article_index',$data);
	}
}